本文分享如何解决因修改WordPress slug导致ERR_TOO_MANY_REDIRECTS问题。

1. 问题描述

我用Windows Live Writer发布了一篇slug为wordpress-load-google-open-sans的博文,随后,在WLW修改slug为`wordpress-load-google-open-sans-normally,再次发布。访问该博文,提示“ERR_TOO_MANY_REDIRECTS”错误,无法正常访问。

使用Redirect Checker工具查询该博文的重定向情况,部分结果如下:

<!-- Result: -->
http://sparkandshine.net/wordpress-load-google-open-sans-normally/
302 Found
http://sparkandshine.net/wordpress
301 Moved Permanently
http://sparkandshine.net/wordpress/
301 Moved Permanently
http://sparkandshine.net/wordpress-from-sae-to-aws-batch-change-images-url/
302 Found
http://sparkandshine.net/wordpress
301 Moved Permanently
http://sparkandshine.net/wordpress/
301 Moved Permanently
http://sparkandshine.net/wordpress-from-sae-to-aws-batch-change-images-url/
...

<!-- Problems found: -->
Too many redirects. 
You use 301 and 302 redirect at the same time. 
You use a 302 redirect

2. 问题的原因

模糊重定向

WP URL auto complete feature,

StackExchange: Disable Wordpress URL auto complete

3. 一些没用的方法

(1)删除重定向插件

删除重定向插件Redirections,还是不能解决问题。

(2)删除旧别名

查找和删除旧域名的SQL语句如下:

-- 查询别名
SELECT * 
FROM  `wp_postmeta` 
WHERE  `meta_key` =  '_wp_old_slug'
AND  `meta_value` LIKE  '%wordpress-load-google-open-sans%'

-- 删除旧别名
SELECT * 
FROM  `wp_postmeta` 
WHERE  `meta_key` =  '_wp_old_slug'
AND  `meta_value` =  'wordpress-load-google-open-sans%'

-- 删除所有旧别名(谨慎,建议先备份)
DELETE FROM `wp_postmeta` WHERE `meta_key` = '_wp_old_slug'

操作示意图如下:

img

然而并没什么卵用。

(4)其他

修改Permalink,再改回来。后台删除文章,重新发布。

3. 解决

期待您的指点。

本文系Spark & Shine原创,转载需注明出处本文最近一次修改时间 2022-04-17 17:26

results matching ""

    No results matching ""